/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hnly.djdl

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.insets.ProvideWindowInsets
import com.hnly.djdl.home.HomeSections
import com.hnly.djdl.home.MainBottomBar
import com.hnly.djdl.theme.MainTheme
import com.google.accompanist.insets.systemBarsPadding
import com.hnly.djdl.components.MainScaffold

@Composable
fun MainApp() {
    ProvideWindowInsets(consumeWindowInsets = true, windowInsetsAnimationsEnabled = true) {
        MainTheme {
            val tabs = remember { HomeSections.values() }
            val navController = rememberNavController()
            MainScaffold(
                modifier = Modifier.systemBarsPadding(false),
                bottomBar = {
                    MainBottomBar(navController = navController, tabs = tabs)
                }
            ) { innerPaddingModifier: PaddingValues ->
                MainNavGraph(
                    navController = navController,
                    modifier = Modifier.padding(innerPaddingModifier)
                )
            }
        }
    }
}
